package com.transaction.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.transaction.config.R;
import com.transaction.domain.SysStockShareholder;
import com.transaction.service.SysStockShareholderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("StockShareHolder")
public class StockShareHolderController {

    @Autowired
    SysStockShareholderService sysStockShareholderService;


    @GetMapping("getByStockId")
    public R getByStockId(Integer stockId){
        QueryWrapper<SysStockShareholder> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("stock_id",stockId);
        List<SysStockShareholder> list = sysStockShareholderService.list(queryWrapper);
        if (!list.isEmpty()){
            String[] ids = new String[list.size()];
            for (int i = 0; i < list.size(); i++) {
                ids[i]= list.get(i).getShareholderNum();
            }
            return R.successed(ids);

        }
        return R.successed();

    }
}
